home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / etc / dhcp3 / dhclient-exit-hooks.d / rfc3442-classless-routes < prev    next >
Encoding:
Text File  |  2009-03-31  |  1.5 KB  |  43 lines

  1. RUN="yes"
  2.  
  3.  
  4. if [ "$RUN" = "yes" ]; then
  5.  
  6.         if [ x"$new_rfc3442_classless_static_routes" != x"" ]; then
  7.  
  8.                 if [ x"$reason" == x"BOUND" ]; then
  9.                         rfc_routes=($new_rfc3442_classless_static_routes)
  10.  
  11.                         for(( i=0; i < ${#rfc_routes[@]}; )); do
  12.                                 net_length=${rfc_routes[$i]}
  13.  
  14.                                 ((i++))
  15.  
  16.                                 net_address=(0 0 0 0)
  17.                                 for(( j=0; j < $[$net_length / 8 + \
  18.                                     ($net_length % 8 ? 1 : 0)]; j++, i++)); do
  19.  
  20.                                         net_address[$j]=${rfc_routes[$i]}
  21.                                 done
  22.  
  23.                                 gateway=(0 0 0 0)
  24.                                 for (( j=0; j < 4; j++, i++ )); do
  25.                                         gateway[$j]=${rfc_routes[$i]}
  26.                                 done
  27.  
  28.                                 old_IFS="$IFS"
  29.                                 IFS='.'
  30.  
  31.                                 if [ x"$net_length" == x"32" ]; then
  32.                                         /sbin/route add -host "${net_address[*]}" gw "${gateway[*]}"
  33.                                 else
  34.                                         /sbin/route add -net "${net_address[*]}/$net_length" gw "${gateway[*]}"
  35.                                 fi
  36.                                 IFS="$old_IFS"
  37.  
  38.                         done
  39.  
  40.                 fi
  41.         fi
  42. fi
  43.